<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
	<title>登录页</title>
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/js/jquery-easyui-1.5.3/themes/metro-gray/easyui.css">
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/js/jquery-easyui-1.5.3/themes/icon.css">
	<script src="${pageContext.request.contextPath}/js/jquery-easyui-1.5.3/jquery.min.js" type="text/javascript"></script>
	<script src="${pageContext.request.contextPath}/js/jquery-easyui-1.5.3/jquery.easyui.min.js" type="text/javascript"></script>
	<style type="text/css">
		.login_input {margin-top:2em; margin-bottom:2em;}
	</style>
</head>

<body class="easyui-layout" data-options="fit:'true'">
	<div data-options="region:'center'" style="display:table-cell; vertical-align:middle;
		text-align:center; background-image:url('${pageContext.request.contextPath}/images/1.jpg');
		background-repeat:no-repeat; background-size:100% 100%;">
		<div style="border:1px solid white;width:400px; display:inline-block;">
			<img src="${pageContext.request.contextPath}/images/logo.png">
			<div class="login_input">
				<label for="userCode" style="color:#FFFFFF;">账户：</label>
				<input id="userCode" class="easyui-textbox" data-options="prompt:'Username',iconCls:'icon-man'"><br>
			</div>
			<div class="login_input">
				<label for="password" style="color:#FFFFFF;">密码：</label>
				<input id="password" class="easyui-passwordbox" data-options="prompt:'Password',iconCls:'icon-lock'"><br>
			</div>
			<div class="login_input">
				<a id="login_btn" href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-ok'">登录</a>
				<a id="reset_btn" href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'">重置</a>
			</div>
		</div>
	</div>
</body>
<script type="text/javascript">
	$(function() {
		$("#reset_btn").linkbutton({
			onClick : function() {
				$("#userCode").textbox("clear");
				$("#password").textbox("clear");
			}
		});
		
		$("#login_btn").linkbutton({
			onClick : function() {
				$.ajax({
					type : "post",
					url : "${pageContext.request.contextPath}/login",
					dataType : "json",
					data : {
						"userCode" : $("#userCode").textbox("getValue"),
						"password" : $("#password").textbox("getValue")
					},
					success : function(data) {
						if (data.flag) {
							window.location.href = "${pageContext.request.contextPath}/home";
						} else {
							$.messager.alert("异常信息", data.msg, "error");
						}
					},
					error : function() {
						$.messager.alert("异常信息", "服务器异常，请稍后再试！", "error");
					}
				});
			}
		});
	});
</script>
</html>